<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:include href="../manager/menu.xsl" />
	<xsl:include href="../manager/footer.xsl" />
	<xsl:include href="map_menu.xsl" />
	<xsl:include href="../jquery/jquery.xsl"/>
	<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		method="xml" encoding="UTF-8" />
	<xsl:template match="/">
		<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
			<head>
				<title>Manager Framework users</title>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

				<link rel="stylesheet" href="public/manager/css/manager.css"
					type="text/css" media="screen" />
				
				<link rel="stylesheet" href="public/maps/css/editor.css"
					type="text/css" media="screen" />
					
				<xsl:call-template name="jqueryInclude" />
				<script type="text/javascript" src="public/maps/js/editor.js"></script>
				<script type="text/javascript" src="public/manager/js/menu.js"></script>
				<script type="text/javascript" src="public/manager/js/editor.js"></script>

			</head>
			<body>
				<div id="header">
					<img id="logo" src="public/manager/images/bando.png" alt="inovia" />
				</div>
				<xsl:call-template name="displayMenu">
					<xsl:with-param name="selectedMenu" select="string('maps')" />
				</xsl:call-template>


				<div id="PageLeft">
					
					<div id="menutaches">
						<h2>Actions</h2>
						<ul style="margin-left:-15px">
							<li>
								
							</li>
						</ul>
						<hr />
						<xsl:call-template name="mapMenu"></xsl:call-template>
					</div>

					<div id="content">
						<h1 id="pageName" style="width:500px;"> Edit Map </h1>
						<xsl:variable name="nbError" select="count(//error)" />
						<xsl:if test="$nbError!=0">
							<p>
								<xsl:for-each select=".//error">
									<span style="color:red">
										<xsl:value-of select="text" />
									</span>
									<br />
								</xsl:for-each>
							</p>
						</xsl:if>

						<div
							style="margin:10px 0 0 20px;width:850px;padding:5px;border:1px dotted #AAAAAA;background-color:#ECF3E1;">
							<xsl:if test="site/map">
								<xsl:variable name="mid" select="site/map/mid/text()" />
								<xsl:variable name="mname" select="site/map/mname/text()" />
								<xsl:variable name="mmatrice" select="site/map/mmatrice/text()" />
								<xsl:variable name="mfile" select="site/map/mfile/text()" />
								<form action="index.php?action=mapEditor&amp;id={$mid}"
									method="post" ENCTYPE="multipart/form-data">
									<table>
										<tr>
											<td>Map Name :</td>
										</tr>
										<tr>
											<td>
												<input type="text" name="mapname" value="{$mname}" />
											</td>
										</tr>
										<tr>
											<td>Map matrice :</td>
										</tr>
										<tr>
											<td>
												<table id="mapView"
												style="background: url(mapFiles/bg_{$mid}.png) repeat;"
												>
													<xsl:for-each select=".//site/yLines/xLines">
														<xsl:variable name="y" select="position() - 1" />

														<tr style="height: 50px;">
															<xsl:for-each select="xVal">
																<xsl:variable name="x" select="position() - 1" />
																<td class="tdMapView" id="{$x}_{$y}"
																	style="margin: 0; padding: 0;
																background: url(mapFiles/{$mid}/{$x}_{$y}.png) no-repeat;
																 width: 50px; height: 50px;">
																 	<xsl:choose>
																 		<xsl:when test="val = '[0]'">
																 			<img src="public/manager/images/noPoint.png" />
																 		</xsl:when>
																 		<xsl:when test="val = '[door]'">
																 			<img src="public/images/door.png" />
																 		</xsl:when>
																 		<xsl:otherwise>
																 			<a href="#">
																				<img src="public/manager/images/onePoint.png" />
																			</a>
																 		</xsl:otherwise>
																 	</xsl:choose>
																	<!--  img src="mapFiles/{$mid}/{$x}_{$y}.png" / -->
																</td>
															</xsl:for-each>
														</tr>
													</xsl:for-each>
												</table>
												<!--pre>
													 <xsl:value-of select=".//site/map/mmatrice" /> 
												</pre -->
											</td>
										</tr>
										<tr>
											<td>Image :</td>
										</tr>
										<tr>
											<td>
												<img src="mapFiles/mini_{$mid}.png" />
											</td>
										</tr>
										<tr>
											<td>
												Nouvelle Image 
                  							</td>
										</tr>
										<tr>
											<td>
												<input type="file" name="mFile" />
											</td>
										</tr>
										<tr>
											<td>
												Nouveau fond 
                  							</td>
										</tr>
										<tr>
											<td>
												<input type="file" name="mBackground" />
											</td>
										</tr>
										<tr>
											<td>
												<input type="hidden" value="" id="activPoint" name="activPoint" />
												<input type="hidden" value="" id="desactivPoint" name="desactivPoint" />
												<input type="hidden" value="{$mid}" id="mapId" />
												<input type="submit" value="Save changes" />
											</td>
										</tr>
									</table>
								</form>
							</xsl:if>
						</div>
					</div>
				</div>

				<xsl:call-template name="displayFooter" />
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

